/**
 * 公共方法
 * 使用方法：
 * 0.在setup内使用
 *
 * 1.导入
 *  import {getCurrentInstance} from 'vue'
 * 2.导入获取代理
 *  const {proxy} = getCurrentInstance()
 * 3.调用方法
 *  proxy.$common.toSplitTime
 *
 * @type {{}}
 */

import _ from "lodash";

const common = {

}

/**
 * 时间的格式处理
 * @param time
 * @returns {string}
 */
common.toSplitTime = (time)=>{
    time = time ? time.toString().replace(',', '_'):''
    return time
}

common.arrConvertSearchParam = (searchData,page)=>{
    let param = {}
    for (let searchDataKey in searchData) {
        if (!_.isEmpty(searchData[searchDataKey].prop && searchData[searchDataKey].value)) {
            param[searchData[searchDataKey].prop]
                =
                searchData[searchDataKey].value +"!&" + searchData[searchDataKey].condition
        }
    }
    param.pageNumber = page.currentPage;
    param.pageSize = page.pageSize;
    return param
}

export default common